from PyQt5.QtWidgets import QApplication, QTreeWidget
from pgtools.plugins.client.qtwidget_helper import TTreeWidget

data = [(1, '学院', 0),
        (2, '1队', 1),
        (3, '2队', 1),
        (4, '1队1班', 2),
        (5, '1队2班', 2),
        (6, '1队3班', 2),
        (7, '2队1班', 3),
        (8, '2队2班', 3),
        (9, '2队3班', 3),
        ]
app = QApplication([])
tree = QTreeWidget()
t_tree = TTreeWidget(tree, data, ['单位'])

print(t_tree.get_data())  # 打印所有树形数据


def click_tree(row, col, text):
    print(row, col, text)  # 打印当前点击的树形元素的行，列和值
    print(t_tree.get_current_item())  # 获取当前元素的（id，数据，pid）


t_tree.set_func_item_clicked(click_tree)

tree.show()
app.exec_()
